package org.activequant.tradesystem.ib;

import java.util.HashMap;
import java.util.Map;

import org.activequant.core.domainmodel.InstrumentSpecification;
import org.activequant.core.domainmodel.marketscanner.InstrumentSpecificationDetails;
import org.activequant.core.domainmodel.marketscanner.ScanCriteria;
import org.activequant.util.pattern.events.IEventListener;
/**
 * This class provides us with info about the occurrence of an instrument in various scan lists(scanCriteria) 
 * Holds the following associated variables:
 * <ul>
 * <li>criterias(Map&lt;ScanCriteria,Integer&gt;)</li>
 * <li>instrumentSpecificationDetails(InstrumentSpecificationDetails)</li>
 * <li>listener(IEventListener&lt;InstrumentSpecificationDetails&gt;)</li>
 * </ul>
 * @author Dimitar
 *
 */
public class InstrumentStats {
	/**
	 * private Map&lt;ScanCriteria,Integer&gt; criterias;
	 */
	private Map<ScanCriteria,Integer> criterias;
	/**
	 * private InstrumentSpecificationDetails instrumentSpecificationDetails;
	 */
	private InstrumentSpecificationDetails instrumentSpecificationDetails;
	
	public InstrumentStats(){
		criterias=new HashMap<ScanCriteria,Integer>();
	} 
	/**
	 * Maps the given scanCriteria(ScanCriteria) - instrumentRanking(int) pair into the associated criterias(Map&lt;ScanCriteria,Integer&gt;)
	 * @param scanCriteria
	 * @param instrumentRanking
	 */
	public void addMatchingCriteria(ScanCriteria scanCriteria, int instrumentRanking){
		criterias.put(scanCriteria, instrumentRanking);
	}
	/**
	 * returns the associated criterias(Map&lt;ScanCriteria,Integer&gt;)
	 * @return
	 */
	public Map<ScanCriteria, Integer> getCriterias() {
		return criterias;
	}
	/**
	 * returns the associated instrumentSpecificationDetails(InstrumentSpecificationDetails)
	 * @return
	 */
	public InstrumentSpecificationDetails getInstrumentSpecificationDetails() {
		return instrumentSpecificationDetails;
	}
	/**
	 * sets the associated instrumentSpecificationDetails(InstrumentSpecificationDetails)
	 * @param instrumentSpecificationDetails
	 */
	public void setInstrumentSpecificationDetails(InstrumentSpecificationDetails instrumentSpecificationDetails) {
		this.instrumentSpecificationDetails = instrumentSpecificationDetails;
	}
	/**
	 * public final IEventListener&lt;InstrumentSpecificationDetails&gt; listener = new IEventListener&lt;InstrumentSpecificationDetails&gt;() {...}
	 */
	public final IEventListener<InstrumentSpecificationDetails> listener = new IEventListener<InstrumentSpecificationDetails>() {
		public void eventFired(InstrumentSpecificationDetails event) {
			InstrumentSpecification spec=event.getInstrumentSpecification();
			instrumentSpecificationDetails=event;
			//instrumentSpecificationDao.update(spec);
			//instrumentSpecificationDetailsDao.update(event);
		}
	};
	
}
